package com.dgut.experiment2.component;

import com.dgut.experiment2.event.NotiveEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class NotiveListenr implements ApplicationListener<NotiveEvent>{
    private static final Logger logger= LoggerFactory.getLogger(NotiveListenr.class);

    @Override
    public void onApplicationEvent(NotiveEvent notiveEvent) {
        logger.info("事件监听器获取到NotiveEvent,睡眠当前线程2秒...");
        try {
            Thread.sleep(2000);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        logger.info("NotiveEvent的message属性是：{}",notiveEvent.getMessage());
    }
}
